<!--
 * @Author: 徐伟杰
 * @Date: 2022-10-11 15:18:14
 * @LastEditors: 黄宇/Hyuishine
 * @LastEditTime: 2024-05-16 14:31:31
 * @Description: 
 * @Email: 1529315455@qq.com
 * @Company: 3xData
 * @youWant: 整改机构信息变更页面
-->

<template>
  <view class="container_page">
    <!-- 顶部自定义导航栏 -->
    <action-bar :options="navOptions" />
    <view class="main">
      <uni-section title="机构基本信息" type="line">
        <!-- 机构名称 -->
        <view class="formItem">
          <view class="label required">机构名称</view>
          <input class="content" v-model="form.name" placeholder="请输入机构名称" />
        </view>

        <!-- 统一信用代码 -->
        <view class="formItem">
          <view class="label required">统一信用代码</view>
          <input class="content" v-model="form.code" placeholder="请输入统一信用代码" />
        </view>

        <!-- 所属地区 -->
        <view class="formItem">
          <view class="label required">所属地区</view>
          <input class="content" disabled="true" @tap="openLevel" v-model="form.areas" placeholder="请选择所属地区" />
          <level-linkage ref="levelLinkage" :pickerValueDefault="pickerValueDefault" :allData="treeData"
            @onConfirm="onConfirm" themeColor='#007AFF'></level-linkage>
        </view>

        <!-- 机构地址 -->
        <view class="formItem">
          <view class="label required">机构地址</view>
          <input class="content" v-model="form.address" placeholder="请输入机构地址" />
        </view>

        <!-- 服务机构类型 -->
        <view class="formItem flex justify-between" style="align-items: flex-start; padding: 24rpx">
          <view class="label required">服务机构类型</view>
          <view class="flex flex-direction" style="width: 55%">
            <uni-data-checkbox :multiple="true" v-model="form.serviceType" :map="{
              text: 'dictLabel',
              value: 'dictValue'
            }" :localdata="serverTypeList"></uni-data-checkbox>
          </view>
        </view>

        <!-- 单位联系人 -->
        <view class="formItem">
          <view class="label required">单位联系人</view>
          <input class="content" v-model="form.companyName" placeholder="请输入单位联系人" />
        </view>

        <!-- 联系人电话 -->
        <view class="formItem">
          <view class="label required">联系人电话</view>
          <input class="content" v-model="form.companyPhone" placeholder="请输入联系人电话" />
        </view>

        <!-- 营业执照 -->
        <view class="formItem_double">
          <view class="label required">营业执照</view>
          <view v-if="form.businessLicense">
            <encapsulation-preview :fileUrl="form.businessLicense"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="businessLicense" file-mediatype="all"
              @select="select($event, 'businessLicense')"></uni-file-picker>
          </view>

        </view>
      </uni-section>

      <uni-section title="法人信息" type="line">
        <!-- 法定代表人 -->
        <view class="formItem">
          <view class="label required">法定代表人</view>
          <input class="content" v-model="form.personName" placeholder="请输入法定代表人" />
        </view>

        <!-- 法定代表人电话 -->
        <view class="formItem">
          <view class="label required">法定代表人电话</view>
          <input class="content" v-model="form.phone" placeholder="请输入法定代表人电话" />
        </view>

        <!-- 证件类型 -->
        <view class="formItem">
          <view class="label required">证件类型</view>
          <picker mode="selector" class="content" :range="idcardTypeList" range-key="dictLabel"
            @change="idcardTypeChange($event)">
            <input type="text" disabled :value="form.showIdcardType" :placeholder="'请输入证件类型'" />
          </picker>
        </view>

        <!-- 证件号码 -->
        <view class="formItem">
          <view class="label required">证件号码</view>
          <input class="content" v-model="form.idcard" placeholder="请输入证件号码" />
        </view>

        <!-- 人像采集 -->
        <view class="formItem_double" v-if="form.name">
          <view class="label">人像采集 </view>
          <view class="content_image">
            <image mode='widthFix' v-if="form.image" :class="form.image ? 'images' : 'hasnotPhoto'"
              :src="baseApiUrl + form.image" @tap="ViewImage(form.image)" />
            <button class="buttons" type="text" size="mini" v-if="!form.image" @click="nevTo('image')">前往人像采集</button>
            <button class="buttons" type="text" size="mini" v-else
              @click="toPhotoCatch('head', 'image')">重新采集人像</button>
          </view>
        </view>

        <!-- 身份证人面像 -->
        <view class="formItem_double" v-if="form.name">
          <view class="label required">身份证人像面
          </view>
          <view class="content_image">
            <image mode='widthFix' :class="form.positivePhoto ? 'images' : 'hasnotPhoto'"
              :src="form.positivePhoto ? baseApiUrl + form.positivePhoto : baseImgUrl + '/camera/outline_card.png'"
              @tap="ViewImage(form.positivePhoto)" />
            <button class="buttons" type="text" size="mini" v-if="!form.positivePhoto"
              @click="toPhotoCatch('portrait', 'positivePhoto')">前往采集人像</button>
            <button class="buttons" type="text" size="mini" v-show="form.positivePhoto"
              style="background-color: #ff0000;" @click.stop="DelImg($event, 'positivePhoto')">删除当前人像</button>
          </view>
        </view>

        <!-- 身份证人面像 -->
        <view class="formItem_double" v-if="form.name">
          <view class="label required">身份证国徽面
          </view>
          <view class="content_image">
            <image mode="widthFix" :class="form.backPhoto ? 'images' : 'hasnotPhoto'" @tap="ViewImage(form.backPhoto)"
              :src="form.backPhoto ? baseApiUrl + form.backPhoto : baseImgUrl + '/camera/outline_card.png'" />
            <button class="buttons" type="text" size="mini" v-if="!form.backPhoto"
              @click="toPhotoCatch('emblem', 'backPhoto')">前往采集人像</button>
            <button class="buttons" type="text" size="mini" v-show="form.backPhoto" style="background-color: #ff0000;"
              @click.stop="DelImg($event, 'backPhoto')">删除当前人像</button>
          </view>
        </view>
      </uni-section>

      <uni-section title="质量管理体系" type="line">
        <!-- 维护保养检测质量管理体系文件 -->
        <view class="formItem_double" v-if="form.serviceType && form.serviceType.indexOf('1') != '-1'">
          <view class="label required" style="width: 100%">维护保养检测质量管理体系文件</view>
          <view v-if="form.systemFiles">
            <encapsulation-preview ref="preview" :fileUrl="form.systemFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="systemFiles" file-mediatype="all"
              @select="select($event, 'systemFiles')"></uni-file-picker>
          </view>
        </view>

        <!-- 维护保养检测认证证书 -->
        <view class="formItem_double" v-if="form.serviceType && form.serviceType.indexOf('1') != '-1'">
          <view class="label " style="width: 100%">维护保养检测认证证书</view>
          <view v-if="form.authFiles">
            <encapsulation-preview :fileUrl="form.authFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="authFiles" file-mediatype="all"
              @select="select($event, 'authFiles')"></uni-file-picker>
          </view>
        </view>

        <!-- 安全评估过程控制体系文件 -->
        <view class="formItem_double" v-if="form.serviceType && form.serviceType.indexOf('2') != '-1'">
          <view class="label required" style="width: 100%">安全评估过程控制体系文件</view>

          <view v-if="form.systemFiles1">
            <encapsulation-preview :fileUrl="form.systemFiles1"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="systemFiles1" file-mediatype="all"
              @select="select($event, 'systemFiles1')"></uni-file-picker>
          </view>
        </view>

        <!-- 安全评估认证证书 -->
        <view class="formItem_double" v-if="form.serviceType && form.serviceType.indexOf('2') != '-1'">
          <view class="label " style="width: 100%">安全评估认证证书</view>
          <view v-if="form.safetyCertificationFiles">
            <encapsulation-preview :fileUrl="form.safetyCertificationFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="safetyCertificationFiles" file-mediatype="all"
              @select="select($event, 'safetyCertificationFiles')"></uni-file-picker>
          </view>
        </view>
      </uni-section>

      <uni-section title="服务能力" type="line">
        <!-- 检测能力 -->
        <view class="formItem_double">
          <view class="label ">检测能力</view>
          <view class="flex flex-direction" style="width: 100%">
            <uni-data-checkbox :multiple="true" v-model="form.detectionCapability" :map="{
              text: 'dictLabel',
              value: 'dictValue'
            }" :localdata="detection"></uni-data-checkbox>
          </view>
        </view>
        <!-- 建筑消防设施检测附件 -->
        <view class="formItem flex flex-direction" style="align-items: inherit"
          v-if="form.detectionCapability && form.detectionCapability.indexOf('1') != '-1'">
          <view class="label" :class="form.detectionCapability.indexOf('1') != '-1' ? 'required' : ''"
            style="width: 100%">建筑消防设施检测附件</view>
          <view v-if="form.testFiles">
            <encapsulation-preview ref="preview" :fileUrl="form.testFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="testFiles" file-mediatype="all"
              @select="select($event, 'testFiles')"></uni-file-picker>
          </view>
        </view>

        <!-- 建筑电气消防安全附件 -->
        <view class="formItem flex flex-direction" style="align-items: inherit"
          v-if="form.detectionCapability && form.detectionCapability.indexOf('2') != '-1'">
          <view class="label " :class="form.detectionCapability.indexOf('2') != '-1' ? 'required' : ''"
            style="width: 100%">建筑电气消防安全附件</view>
          <view v-if="form.safetyFiles">
            <encapsulation-preview ref="preview" :fileUrl="form.safetyFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="safetyFiles" file-mediatype="all"
              @select="select($event, 'safetyFiles')"></uni-file-picker>
          </view>
        </view>

        <!-- 钢结构防火涂料检测项目附件 -->
        <view class="formItem flex flex-direction" style="align-items: inherit"
          v-if="form.detectionCapability && form.detectionCapability.indexOf('3') != '-1'">
          <view class="label " :class="form.detectionCapability.indexOf('3') != '-1' ? 'required' : ''"
            style="width: 100%">钢结构防火涂料检测项目附件</view>
          <view v-if="form.projectFiles">
            <encapsulation-preview ref="preview" :fileUrl="form.projectFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="projectFiles" file-mediatype="all"
              @select="select($event, 'projectFiles')"></uni-file-picker>
          </view>
        </view>

        <!-- 其他检测能力附件 -->
        <view class="formItem flex flex-direction" style="align-items: inherit"
          v-if="form.detectionCapability && form.detectionCapability.indexOf('4') != '-1'">
          <view class="label " :class="form.detectionCapability.indexOf('4') != '-1' ? 'required' : ''"
            style="width: 100%">其他检测能力附件</view>
          <view v-if="form.otherFiles">
            <encapsulation-preview ref="preview" :fileUrl="form.otherFiles"></encapsulation-preview>
          </view>
          <view class="example-body" v-else>
            <uni-file-picker limit="1" ref="otherFiles" file-mediatype="all"
              @select="select($event, 'otherFiles')"></uni-file-picker>
          </view>
        </view>
      </uni-section>
      <view style="height: 100rpx"></view>
      <view class="btn_box">
        <button class="btn_box-combination audit" v-if="form.state == '1' || form.state == '3'" @click="audit_btn">
          提交审核
        </button>
        <button class="btn_box-combination save" @click="save_btn">
          保存
        </button>
      </view>
    </view>

    <drag-button :isDock="true" :existTabBar="true" :title="title" @btnClick="btnClick" />
    <toast></toast>
  </view>
</template>
<script>
import { baseApiUrl, baseImgUrl } from '@/config.js';
import levelLinkage from "@/components/three-level-linkage/linkage.nvue"
import uploadImg from "../../components/upload/upload-img.vue";
import EncapsulationPreview from '../agency/components/EncapsulationPreview.vue';
import dragButton from "@/components/drag-button/drag-button.vue";
/** dragButton插件文档可查看https://ext.dcloud.net.cn/plugin?id=1087 */
import { mapState } from 'vuex';
export default {
  components: {
    levelLinkage,
    uploadImg,
    EncapsulationPreview,
    dragButton
  },
  computed: {
    ...mapState(['login'])
  },
  watch: {
    'login.form': {
      handler(val) {
        for (let key in val) {
          if (val[key] != '' && val[key] != null) {
            this.$set(this.form, key, val[key])
          }
        }
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      navOptions: {
        // 导航栏配置参数
        left: {
          icon: "back",
        },
        center: {
          title: "机构信息变更",
        },
      },
      baseImgUrl: baseImgUrl,
      baseApiUrl: baseApiUrl,
      form: {
        name: null, // 机构名称
        code: null, // 统一信用代码
        areas: null, // 所属地区(展示)
        area: null, // 所属地区(传值)
        address: null, // 机构地址
        serviceType: null, // 服务机构类型
        companyName: null, // 单位联系人
        companyPhone: null, // 联系人电话
        businessLicense: null, // 营业执照
        personName: null, // 法定代表人
        phone: null, // 法定代表人电话
        showIdcardType: null, // 证件类型(展示)
        idcardType: null, // 证件类型(传值)
        idcard: null, // 证件号码
        image: null, // 人像采集
        positivePhoto: null, // 身份证人像面
        backPhoto: null, // 身份证国徽面
        systemFiles: null, // 维护保养检测质量管理体系文件
        authFiles: null, // 维护保养检测认证证书
        systemFiles1: null, // 安全评估过程控制体系文件
        safetyCertificationFiles: null, // 安全评估认证证书
        detectionCapability: null, // 检测能力
        testFiles: null, // 建筑消防设施检测附件
        safetyFiles: null, // 建筑电气消防安全附件
        projectFiles: null, // 钢结构防火涂料检测项目附件
        otherFiles: null, // 其他检测能力附件
      },
      serverTypeList: [], // 服务机构类型集合
      idcardTypeList: [], // 证件类型集合
      BusinessLicense: [], // 营业执照集合
      detection: [], // 检测能力列表
      pickerValueDefault: [0, 0, 0], // 省市县的值
      treeData: [], // 所属区域
      flag: false,
      imgPath: '/common/upload',

      treeId: [],

      maintenanceId: null,
      abilityId: null,
      safetyId: null,
      agencyId: null,
      title: '日志修改',
      loading: false,
    };
  },
  onShow: function () {
    // if (this.$store.state.unitTask.image) {
    //   this.$set(this.form, 'image', this.$store.state.unitTask.image)
    // }
    // if (this.$store.state.login.form.positivePhoto) {
    //   this.form.positivePhoto = this.$store.state.login.form.positivePhoto
    // }
    // if (this.$store.state.login.form.backPhoto) {
    //   this.form.backPhoto = this.$store.state.login.form.backPhoto
    // }
  },
  onLoad() {
    new Promise((resolve, reject) => {
      // 获取所属地区区域树
      this.getTreelists()
      // 获取证件类型数据
      this.getIdCardList()
      // 获取服务机构类型
      this.getServerType()
      // 获取检测能力列表
      this.getDetection()

      setTimeout(() => {
        resolve()
      }, 1000);
    }).then(() => {
      // 获取机构信息接口
      this.getOrganizeInfo()
    })
  },
  methods: {
    // 获取机构信息接口
    getOrganizeInfo() {
      this.treeId = []
      this.$store.dispatch("organizeInfo_form", "").then((res) => {
        this.form = res.data

        // 回显区域地址
        this.formTree(this.treeData, res.data.area)
        let dist = [res.data.areaName];
        let newDemo = ['无']
        let demo = this.treeId.concat(dist);
        if (demo.length == 2) {
          demo = demo.concat(newDemo)
        }
        this.$set(this.form, "areas", demo)

        // 解析服务机构类型
        let server = res.data.serviceType.split(',')
        this.$set(this.form, "serviceType", server)

        // 解析证件类型
        this.idcardTypeList.forEach(item => {
          if (item.dictValue == res.data.idcardType) {
            this.$set(this.form, "showIdcardType", item.dictLabel)
          }
        })

        // 拼接质量管理体系
        if (server.indexOf('1') != '-1') {
          this.$set(this.form, "systemFiles", res.data?.maintenance?.systemFiles || null)
          this.$set(this.form, "authFiles", res.data?.maintenance?.authFiles || null)
        }
        if (server.indexOf('2') != '-1') {
          this.$set(this.form, "systemFiles1", res.data?.assessSafety?.systemFiles || null)
          this.$set(this.form, "safetyCertificationFiles", res.data?.assessSafety?.safetyCertificationFiles || null)
        }

        // 获取maintenanceId
        this.maintenanceId = res.data.maintenance?.maintenanceId || null
        // 获取abilityId
        this.abilityId = res.data.checkAbility?.abilityId || null
        // 获取safetyId
        this.safetyId = res.data.assessSafety?.safetyId || null
        // 获取agencyId
        this.agencyId = res.data.agencyId || null


        if (res.data.checkAbility) {
          // 解析检测能力类型
          let detectionCapability = res.data?.checkAbility.detectionCapability.split(',')
          this.$set(this.form, 'detectionCapability', detectionCapability)

          // 拼接检测能力
          this.$set(this.form, 'testFiles', res.data?.checkAbility.testFiles)
          this.$set(this.form, 'safetyFiles', res.data?.checkAbility.safetyFiles)
          this.$set(this.form, 'projectFiles', res.data?.checkAbility.projectFiles)
          this.$set(this.form, 'otherFiles', res.data?.checkAbility.otherFiles)
        }

      })
    },
    // 反向递归获取区域树
    formTree(list, id) {
      list.forEach((item) => {
        if (item.children && item.children.length) {
          if (item.children.some((row) => row.id === id)) {
            this.treeId.unshift(item.name);
            this.formTree(this.treeData, item.id);
          } else {
            this.formTree(item.children, id);
          }
        } else {
          return;
        }
      });
    },
    // 解析服务机构类型
    IdCardServer(type) {
      return this.idcardTypeList.forEach(item => {
        if (item.dictValue == type) {
          return item.dictLabel
        }
      })
    },

    // 获取所属地区区域树
    getTreelists() {
      this.$store.dispatch('getTreeList').then(res => {
        this.treeData = res
      })
    },
    // 获取证件类型数据
    getIdCardList() {
      this.$getDict('document_type').then(res => {
        this.idcardTypeList = res
      })
    },
    // 获取服务机构类型
    getServerType() {
      this.$getDict('service_organization_type').then(res => {
        this.serverTypeList = res
      })
    },
    // 获取检测能力列表
    getDetection() {
      this.$getDict('detection_capability').then(res => {
        this.detection = res
      })
    },
    // 打开三级联动功能
    openLevel() {
      this.$refs.levelLinkage.open();
    },
    // 选择省市县后确定事件
    onConfirm(e) {
      this.form.areas = e.name
      this.form.area = e.thirdPick.id
    },
    // 营业执照上传成功回调函数
    test(e, label) {
      this.form[label] = e.join(",");
    },
    // 解析图片url链接
    getUrl(url) {
      if (url) {
        return this.baseApiUrl + url
      }
    },
    // 对预览图片路径进行处理
    getImgUrl(url) {
      if (url) {
        if (url.indexOf('http') < 0) {
          url = this.$baseApiUrl + url;
        }
        url = url.replace(/\\/g, '/');
        return encodeURI(url);
      } else {
        return url;
      }
    },
    // 预览图片
    ViewImage(url) {
      if (url) {
        var path = url.split(',');
        path = path.map(item => {
          return this.getImgUrl(item);
        });
        uni.previewImage({
          urls: path,
          current: 0
        });
      }
    },
    // 前往人像采集
    nevTo(fileUrls) {
      uni.navigateTo({
        url: '../../pages_workTableChild/peopleManage/recognition?photoType=true&label=' + fileUrls
      })
    },
    // 跳往拍照证件页面
    toPhotoCatch(type, label) {
      // 防止重复点击
      if (!this.flag) {
        this.flag = true;
        uni.navigateTo({
          url: '/pages/login/components/photoCatch?photoType=' + type + '&label=' + label,
          success: () => {
            this.flag = false;
          }
        })
      } else {
        this.$showToast({
          show: true,
          text: '正在前往拍照页面，请稍后'
        });
      }
    },
    // 删除图片
    DelImg(e, label) {
      uni.showModal({
        title: '提示',
        content: '确定要删除这张图片吗？',
        cancelText: '取消',
        confirmText: '去掉',
        success: res => {
          if (res.confirm) {
            this.form[label] = ''
          }
        }
      });
    },

    // 获取上传状态
    select(e, key) {
      let that = this
      let size = e.tempFiles[0].size
      if (size <= 1024 * 1024 * 20) {
        uni.uploadFile({
          url: this.baseApiUrl + this.imgPath, //仅为示例，非真实的接口地址
          filePath: e.tempFilePaths[0],
          name: 'file',
          formData: {
            'user': 'test'
          },
          success: (uploadFileRes) => {
            let dist = JSON.parse(uploadFileRes.data)
            if (dist.code == '200') {
              that.$set(that.form, key, dist.fileName)
              that.$forceUpdate()
              // this.$refs.preview.fileUrl = dist.fileName
            } else {
              uni.showToast({
                title: '上传失败',
                icon: "none",
                duration: 2000
              })
            }
          }
        });
      } else {
        this.$refs[key].clearFiles()
        uni.showToast({
          title: '文件过大',
          icon: "none",
          duration: 2000
        })
      }
    },
    // 获取上传进度
    progress(e) {
      console.log('上传进度：', e)
    },

    // 上传成功
    success(e) {
      console.log('上传成功')
    },

    // 上传失败
    fail(e) {
      console.log('上传失败：', e)
    },

    // 确定
    idcardTypeChange(e) {
      this.form.idcardType = this.idcardTypeList[e.detail.value].dictValue;
      this.form.showIdcardType = this.idcardTypeList[e.detail.value].dictLabel;
    },

    // 保存
    save_btn() {
      // if (this.loading) return

      this.loading = true
      uni.showLoading({
        title: '正在加载请稍后',
        mask: true
      });

      let that = this
      if (this.form.serviceType.indexOf('1') != '-1') {
        if (this.form.systemFiles == null || this.form.systemFiles == '') {
          uni.showToast({
            title: '质量管理体系缺少参数',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }
      if (this.form.serviceType.indexOf('2') != '-1') {
        if (this.form.systemFiles1 == null || this.form.systemFiles1 == '') {
          uni.showToast({
            title: '质量管理体系缺少参数',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }
      if (this.form.detectionCapability.indexOf('1') != '-1') {
        if (this.form.testFiles == null || this.form.testFiles == '') {
          uni.showToast({
            title: '请上传建筑消防设施检测附件',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }
      if (this.form.detectionCapability.indexOf('2') != '-1') {
        if (this.form.safetyFiles == null || this.form.safetyFiles == '') {
          uni.showToast({
            title: '请上传建筑电气消防安全附件',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }
      if (this.form.detectionCapability.indexOf('3') != '-1') {
        if (this.form.projectFiles == null || this.form.projectFiles == '') {
          uni.showToast({
            title: '请上传钢结构防火涂料检测项目附件',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }
      if (this.form.detectionCapability.indexOf('4') != '-1') {
        if (this.form.otherFiles == null || this.form.otherFiles == '') {
          uni.showToast({
            title: '请上传其他检测能力附件',
            icon: 'none',
            duration: 1500
          })
          return
        }
      }

      let form = {
        name: this.form.name, // 机构名称
        code: this.form.code, // 统一信用代码
        area: this.form.area, // 所属区域(传给后端)
        address: this.form.address, // 机构地址
        serviceType: this.form.serviceType.join(','), // 服务机构类型
        companyName: this.form.companyName, // 联系人
        companyPhone: this.form.companyPhone, // 联系人电话
        businessLicense: this.form.businessLicense, // 营业执照附件

        personName: this.form.personName, // 法定代表人
        phone: this.form.phone, // 法定代表人联系电话
        idcardType: this.form.idcardType, // 证件类型
        idcard: this.form.idcard, // 证件号码
        image: this.form.image, // 人像采集
        positivePhoto: this.form.positivePhoto, // 身份证人像面
        backPhoto: this.form.backPhoto, // 身份证国徽面

        maintenance: {
          systemFiles: this.form.systemFiles || '', // 维护保养检测质量管理体系文件
          authFiles: this.form.authFiles || '', // 维护保养检测认证证书
          maintenanceId: this.maintenanceId,
          agencyId: this.agencyId
        },

        assessSafety: {
          systemFiles: this.form.systemFiles1 || '', // 安全评估过程控制体系文件
          safetyCertificationFiles: this.form.safetyCertificationFiles || '', // 安全评估认证证书
          safetyId: this.safetyId,
          agencyId: this.agencyId
        },

        checkAbility: {
          detectionCapability: this.form.detectionCapability.join(','), // 检测能力
          testFiles: this.form.testFiles, // 建筑消防设施检测附件
          safetyFiles: this.form.safetyFiles, // 建筑电气消防安全附件
          projectFiles: this.form.projectFiles, // 钢结构防火涂料检测项目附件
          otherFiles: this.form.otherFiles, // 其他检测能力附件
          abilityId: this.abilityId, // 
          agencyId: this.agencyId
        },
        agencyId: this.agencyId
      }
      this.$store.dispatch('organizeInfo_update', form)
        .then(res => {
          if (res.code == 200) {
            uni.showToast({
              title: '修改成功',
              icon: 'none',
              duration: 1500
            })
            that.$store.commit('saveAuditState', 3)
            that.$nextTick(() => {
              that.getOrganizeInfo()
            })
          } else {
            uni.showToast({
              title: '修改失败',
              icon: 'error',
              duration: 1500
            })
          }
        }).finally(() => {
          let timer = setTimeout(() => {
            this.loading = false
            uni.hideLoading();
            clearTimeout(timer)
          }, 3000);
        })
    },
    // 提交审核
    audit_btn() {
      if (this.loading) return

      this.loading = true
      uni.showLoading({
        title: '正在加载请稍后',
        mask: true
      });
      let that = this
      uni.showModal({
        title: '提示',
        content: '请确保保存后在提交审核！否则未保存的数据将不进行提交审核',
        success: function (res) {
          if (res.confirm) {
            let data = {
              agencyId: that.agencyId,
            }
            that.$store.dispatch('audit_agencyInfo', data).then(res => {
              if (res.code == 200) {
                that.$store.commit('saveAuditState', 0)
                uni.showToast({
                  title: '操作成功',
                  icon: 'none',
                  duration: 1500
                })
                that.$nextTick(() => {
                  that.getOrganizeInfo()
                })
              } else {
                uni.showToast({
                  title: '操作失败',
                  icon: 'none',
                  duration: 1500
                })
              }
            }).finally(() => {
              let timer = setTimeout(() => {
                this.loading = false
                uni.hideLoading();
                clearTimeout(timer)
              }, 3000);
            })
          } else if (res.cancel) {
            console.log('用户点击取消');
          }
        }
      });
    },
    btnClick() {
      uni.navigateTo({
        url: "/pages_workTableChild/organizeInforChange/journal?agencyId=" + this.agencyId
      })
    },
    auditClick() {

    },
    btnTouchstart() {
      console.log('btnTouchstart');
    },
    btnTouchend() {
      console.log('btnTouchend');
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.main {
  background: $OVERALL_SITUATION_BACKGROUND_GRADIENT;
  position: relative;

  .btn_box {
    width: 100%;
    height: 100rpx;
    background-color: #fff;
    position: fixed;
    display: flex;
    flex-direction: row;
    z-index: 9;
    bottom: 0;
    padding: 10rpx;

    &-combination {
      flex: 1;
      height: 80rpx;
      text-align: center;
      line-height: 80rpx;
      margin: 0 40rpx;
      color: #fff;
      font-size: 26rpx;
    }

    .audit {
      background: #D9EBFF;
      color: #0090FE;
    }

    .save {
      background: $OVERALL_CONFIRM_BUTTON_COLOR;
    }
  }
}

::v-deep .uni-section {
  margin-top: 0 !important;
  background-color: transparent !important;
}

::v-deep .uni-data-checklist .checklist-group .checklist-box {
  margin-right: 0 !important;
}

.formItem {
  display: flex;
  align-items: center;
  min-height: 110rpx;
  background: white;
  width: calc(100% - 40rpx);
  margin: 0 auto 14rpx;
  padding: 0 24rpx;
  border-radius: 20rpx;

  .label {
    color: #333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 36rpx;
    width: 35%;
  }

  .required {
    &::before {
      content: "*";
      margin: 0 10rpx;
      color: #ea0707;
    }
  }

  .content {
    flex: 1;
    text-align: right;
    font-size: 28rpx;
  }
}

.formItem_double {
  display: flex;
  flex-direction: column;
  min-height: 110rpx;
  background: white;
  width: calc(100% - 40rpx);
  margin: 0 auto 14rpx;
  padding: 24rpx;
  border-radius: 20rpx;

  .label {
    color: #333;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 36rpx;
    width: 35%;
  }

  .required {
    &::before {
      content: "*";
      margin: 0 10rpx;
      color: #ea0707;
    }
  }

  .content {
    flex: 1;
    text-align: right;
    font-size: 28rpx;
  }

  .content_image {
    display: flex;
    justify-content: space-between;
    align-items: flex-end
  }
}

.images {
  width: 150rpx;
  height: 250rpx;
  border: 1rpx solid #e5e5e5;
  margin-top: 20rpx
}

.buttons {
  background-color: #1AB1FF;
  font-size: 24rpx;
  color: #FFFFFF;
  margin-top: 20rpx;
  margin-right: 0;
  height: 50rpx;
  line-height: 50rpx;
}

.hasnotPhoto {
  width: 240rpx;
  margin-top: 20rpx;
}

.example-body {
  margin-top: 20rpx;

}

::v-deep .uni-file-picker .uni-file-picker__files .files-button uni-button {
  background-color: #1AB1FF;
}

::v-deep .drag {
  background: $OVERALL_CONFIRM_BUTTON_COLOR;
  color: #fff
}
</style>